package com.movie.datacomm.common;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class CommResp {
    private int success_code;
    private int error_code;
    private String message;
    private Object data;
    private long total;

    public static CommResp ok(String msg){
        CommResp rsp = new CommResp();
        rsp.setSuccess_code(200);
        rsp.setMessage(msg);
        return rsp;
    }

    public static CommResp ok(Object data){
        CommResp rsp = new CommResp();
        rsp.setSuccess_code(200);
        rsp.setData(data);
        return rsp;
    }

    public static CommResp okList(Object data, long total){
        CommResp rsp = new CommResp();
        rsp.setSuccess_code(200);
        rsp.setData(data);
        rsp.setTotal(total);
        return rsp;
    }

    public static CommResp ok(){
        CommResp rsp = new CommResp();
        rsp.setSuccess_code(200);
        return rsp;
    }

    public static CommResp ok(int code){
        CommResp rsp = new CommResp();
        rsp.setSuccess_code(code);
        return rsp;
    }

    public static CommResp ok(int code, String msg){
        CommResp rsp = new CommResp();
        rsp.setSuccess_code(code);
        rsp.setMessage(msg);
        return rsp;
    }

    public static CommResp fail(String msg){
        CommResp rsp = new CommResp();
        rsp.setError_code(1);
        rsp.setMessage(msg);
        return rsp;
    }

    public static CommResp fail(int code, String msg){
        CommResp rsp = new CommResp();
        rsp.setError_code(code);
        rsp.setMessage(msg);
        return rsp;
    }

}
